package day8;

/**
 * @author oldliu
 * @since 1.0
 */
public class Teacher {
    private String name;
    private int age;

    public Teacher(){

    }

    public Teacher(String name, int age) {
        //this.name = name;
        //this.age = age;
        this.setName(name);
        this.setAge(age);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if(age<20||age>=60){
            System.out.println("年龄"+age+"不合理");
            System.out.println("设置失败");
            return;
        }
        this.age = age;
    }

    public void selfIntro(){
        System.out.println("我叫"+name+"，今年"+age+"岁了");
    }

}
